package com.example.travel.service.impl;

import com.example.travel.entity.Scenic;
import com.example.travel.entity.ScenicImg;
import com.example.travel.entity.bo.OrderformBO;
import com.example.travel.entity.dto.OrderformDTO;
import com.example.travel.entity.dto.ScenicDTO;
import com.example.travel.mapper.ScenicMapper;
import com.example.travel.service.IScenicService;
import com.example.travel.util.OrderNumberUtil;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class ScenicService implements IScenicService {

    @Autowired
    private ScenicMapper scenicMapper;

    @Override
    public PageInfo<Scenic> queryScenicPage(ScenicDTO scenicDTO) {
        PageHelper.startPage(scenicDTO.getPageNum(),scenicDTO.getPageSize());
        List<Scenic> list =  scenicMapper.queryScenicPage(scenicDTO);
        return new PageInfo<>(list);
    }

    @Override
    public List<ScenicImg> queryImgInfomation(ScenicImg scenicImg) {
        return scenicMapper.queryImgInfomation(scenicImg);
    }

    @Override
    public boolean placeAnOrder(OrderformDTO orderformDTO) {
        orderformDTO.setOrderNumber(OrderNumberUtil.getOrderNumber());
        return scenicMapper.placeAnOrder(orderformDTO);
    }

    @Override
    public PageInfo<OrderformBO> queryOrderForm(OrderformDTO orderformDTO) {
        PageHelper.startPage(orderformDTO.getPageNum(),orderformDTO.getPageSize());
        List<OrderformBO> list = scenicMapper.queryOrderForm(orderformDTO);
        return new PageInfo<>(list);
    }
}
